<!--地区插件 3级联动-->
// _init_area();
// var Gid  = document.getElementById ;
// var showArea = function(){
//     Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +
//         Gid('s_city').value + " - 县/区" +
//         Gid('s_county').value + "</h3>"
// }
// Gid('s_county').setAttribute('onchange','showArea()');
$(".loginBox .loginDiv ul li .loginSelect1:nth-child(3)").css({'margin-right':'0','float':'right','position':'absolute','right':'0','top':'0'});

//权限角色
var tenantsDetailDictionFunction = function(){
    $.ajax({
        url:"systemRole/findAllRoleByTypePage.json",
        type:'GET',
        dataType:"json",
        data:{
            roleType:1,page:1,pageNum:1000
        },
        success:function(result){
            var tem = "";
            $.each( result.roleList, function(index, content){
                if(content.code != '001'){
                    tem += "<option value='"+content.id+"'>"+content.roleName+"</option>";
                }
            });
            // $("#tenantsDetailDiction").empty();
            // $("#tenantsDetailDiction").append(tem);
        }
    });
}();

//职业角色
var tenantsDetailOccupationFunction = function(){
    $.ajax({
        url:"systemRole/findAllRoleByTypePage.json",
        type:'GET',
        dataType:"json",
        data:{
            roleType:2,page:1,pageNum:1000
        },
        success:function(result){
            var tem = "";
            $.each( result.roleList, function(index, content){
                if(content.id == 10){
                    tem += "<option value='"+content.id+"' selected='selected'>"+content.roleName+"</option>";
                }else {
                    tem += "<option value='"+content.id+"'>"+content.roleName+"</option>";
                }
            });
            $("#tenantsDetailOccupation").empty();
            $("#tenantsDetailOccupation").append(tem);

        }
    });
}();

//根据市查询所有区
var countyFunction = function(city){
    $.ajax({
        url:"cityWeb/findAllAreaByCity.json",
        type:'POST',
        dataType:"json",
        data:{
            city:city
        },
        success:function(result){
            var tem = "<option value=''>区域</option>";
            $.each( result.byOpenCityList, function(index, content){
                tem += "<option value='"+content.area+"'>"+content.area+"</option>";
            });
            $("#s_county").empty();
            $("#s_county").append(tem);
            $(".loginBox .loginDiv ul li .loginSelect1:nth-child(3)").css({'margin-right':'0','float':'right','position':'absolute','right':'0','top':'0'});
        }
    });
}

//根据省份查询所有市
var cityFunction = function(province){
    $.ajax({
        url:"cityWeb/findAllCityByProvince.json",
        type:'POST',
        dataType:"json",
        data:{
            province:province
        },
        success:function(result){
            var tem = "<option value=''>城市</option>";
            $.each( result.byOpenCityList, function(index, content){
                tem += "<option value='"+content.city+"'>"+content.city+"</option>";
            });
            $("#s_city").empty();
            $("#s_city").append(tem);
            $(".loginBox .loginDiv ul li .loginSelect1:nth-child(3)").css({'margin-right':'0','float':'right','position':'absolute','right':'0','top':'0'});
        }
    });
}

//获取开通省份
var provinceFunction = function(){
    $.ajax({
        url:"cityWeb/findAllProvince.json",
        type:'GET',
        dataType:"json",
        success:function(result){
            var tem = "<option value=''>省份</option>";
            $.each( result.byOpenCityList, function(index, content){
                tem += "<option value='"+content.province+"'>"+content.province+"</option>";
            });
            $("#s_province").empty();
            $("#s_province").append(tem);
            $(".loginBox .loginDiv ul li .loginSelect1:nth-child(3)").css({'margin-right':'0','float':'right','position':'absolute','right':'0','top':'0'});
        }
    });
}();

function provinceChange(){
    var options=$("#s_province option:selected");
    cityFunction(options.val());
}

function cityChange () {
    var options=$("#s_city option:selected");
    countyFunction(options.val());
}

//提交注册
function tenantsDetailSubmit(){
    if($("#tenantsDetailDiction option:selected").val() == ''){
        alert("请选择商家类型");
    }else if($("#tenantsDetailOccupation option:selected").val() == ''){
        alert("请选择商家职业");
    }else if($("#s_county option:selected").val() == ''){
        alert("请选择省市区");
    }else {
        $.ajax({
            url: "registerWeb/submitBizTenantsDetailWeb.json",
            type: 'POST',
            dataType: "json",
            data: $("#tenantsDetailForm").serialize(),
            success: function (result) {
                if (result.isOK == "OK") {
                    window.location.href = "/";
                }else {
                    alert(result.msg);
                }
            },
            error: function () {
                alert("请求失败");
            }
        });
    }
}